#include "laurin-80211-network-set.h"



Laurin80211NetworkSet::~Laurin80211NetworkSet()
{
	_networks.clear();
}


Laurin80211Network* Laurin80211NetworkSet::isNetworkPresent(u_int8_t* bssid)
{
	std::list<Laurin80211Network>::iterator b = _networks.begin();
	std::list<Laurin80211Network>::iterator e = _networks.end();

	while(b != e)
	{
		if(b->isAccessPointPresent(bssid))
			return &(*b);

		b++;
	}

	return NULL;
}


Laurin80211Network* Laurin80211NetworkSet::isNetworkPresent(Glib::ustring ssid)
{

	std::list<Laurin80211Network>::iterator b = _networks.begin();
	std::list<Laurin80211Network>::iterator e = _networks.end();

	while(b != e)
	{
		if(ssid == b->getSSID())
			return &(*b);

		b++;
	}

	return NULL;

}


bool Laurin80211NetworkSet::addNetwork(Glib::ustring ssid, bool check)
{
	return addNetwork(Laurin80211Network(ssid), check);
}


bool Laurin80211NetworkSet::addNetwork(const Laurin80211Network& network, bool check)
{
	if(check && isNetworkPresent(network.getSSID()) != NULL)
		return false;

	_networks.push_front(network);
	return true;
}


std::list<Laurin80211Network>* Laurin80211NetworkSet::getNetworks()
{
	return &_networks;
}


